/*
 * Copyright 2012 Alain Pannetrat (L1L1@gmx.com)
 * 
 * This file is part of cookie-miner.
 * 
 * cookie-miner is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version.
 * 
 * cookie-miner is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License 
 * along with cookie-miner. If not, see http://www.gnu.org/licenses/.
 *
 * @version: $Id$
 *
 */
#ifndef BUFIO_SSL_H
#define BUFIO_SSL_H

#include "bufio.h"
#include <openssl/ssl.h>

class BufferInOutSSL : public BufferInOutSocket {
	public:
		static BufferInOutSSL* create(int filedes, 
				bool is_server,
				EVP_PKEY *privkey = NULL,
				unsigned certlen  = 0,
				X509 **certchain  = NULL ); /* named constructor */
		SSL* get_ssl() { return _ssl; }
		virtual bool read_load();
		virtual bool write_flush();
		virtual ~BufferInOutSSL();
	protected:
		BufferInOutSSL(int filedes = -1);

	private:		
		SSL_CTX* _ssl_ctx;
		SSL* _ssl;

		DISALLOW_COPY_AND_ASSIGN(BufferInOutSSL);
};

#endif
